package com.mlnx.ecg.ui.model;

public class RectF {

	public float left;
	public float top;
	public float getTop() {
		return top;
	}

	public float right;
	public float bottom;

	public RectF() {
	}

	public RectF(float left, float top, float right, float bottom) {
		this.left = left;
		this.top = top;
		this.right = right;
		this.bottom = bottom;
	}

	/**
	 * Returns true if the rectangle is empty (left >= right or top >= bottom)
	 */
	public final boolean isEmpty() {
		return left >= right || top >= bottom;
	}

	/**
	 * @return the rectangle's width. This does not check for a valid rectangle
	 *         (i.e. left <= right) so the result may be negative.
	 */
	public final float width() {
		return right - left;
	}

	/**
	 * @return the rectangle's height. This does not check for a valid rectangle
	 *         (i.e. top <= bottom) so the result may be negative.
	 */
	public final float height() {
		return bottom - top;
	}

	/**
	 * @return the horizontal center of the rectangle. This does not check for a
	 *         valid rectangle (i.e. left <= right)
	 */
	public final float centerX() {
		return (left + right) * 0.5f;
	}

	/**
	 * @return the vertical center of the rectangle. This does not check for a
	 *         valid rectangle (i.e. top <= bottom)
	 */
	public final float centerY() {
		return (top + bottom) * 0.5f;
	}

	/**
	 * Set the rectangle to (0,0,0,0)
	 */
	public void setEmpty() {
		left = right = top = bottom = 0;
	}

	public boolean isPonitInRect(int x, int y) {
		return x > left && right > x && y > top && bottom > y;
	}
}
